#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;
/*
收获：注意一些基本的概念，例如 a b的最小公倍数应该为 a * b / gcd(a, b);

牢记一些gcd函数的写法
int gcd(int a, int b){
    return b == 0 ? a : gcd(b, a % b);
}
*/

LL gcd(LL a, LL b){
    return b == 0 ? a : gcd(b, a % b);
}

LL f(LL a1, LL n, LL d){
    LL res = n * a1 + n * (n - 1) / 2 * d;
    return res;
}

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    LL n, a, b;
    LL kk;
    cin >> n >> a >> b;
    LL pp = gcd(a, b);
    kk = a * b / pp;

    LL num = f(1, n, 1);
    LL k1 = f(a, n / a, a);
    LL k2 = f(b, n / b, b);
    LL k3 = f(kk, n / kk, kk);
    cout << num - k1 - k2 + k3<< '\n';


    return 0;
}